package com.sti.platform.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.aisino.core.dao.BaseDao;
import com.aisino.tools.enums.PageEnum;
import com.aisino.tools.enums.QlEnum;
import com.aisino.tools.util.page.Page;
import com.sti.platform.dao.ExpertDao;
import com.sti.platform.model.Degree;
import com.sti.platform.model.Expert;
import com.sti.platform.model.MaJor;
import com.sti.platform.model.Position;

@Repository
public class ExpertDaoImpl extends BaseDao implements ExpertDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<Expert> queryList(String sql, Page page) {
		Integer total = super.getTotalCount(sql, null, null,  QlEnum.SQL);
		page.setTotal(total);
		
		return super.getByHibernateQuery(sql, null, null, 1000,
				page, Expert.class,QlEnum.SQL, PageEnum.PAGE_YES).getRecord();
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Expert> queryExperts(String sql){
		return super.getBySql(sql, Expert.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Degree> queryDegrees() {
		String sql = "SELECT * FROM sys_degree WHERE status = 0";
		return super.getBySql(sql, Degree.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<MaJor> queryMaJors() {
		String sql = "SELECT * FROM sys_major WHERE status = 0";
		return super.getBySql(sql, MaJor.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Position> queryPositions() {
		String sql = "SELECT * FROM sys_position WHERE status = 0";
		return super.getBySql(sql, Position.class);
	}

}
